<!--显示当前用户列表-->
<table id="userListGrid"></table>
<script>
    $(function () {
        $('#userListGrid').datagrid({
            toolbar: '#toolbar',
            title: '用户列表',
            iconCls: 'icon icon-chart_organisation',
            rownumbers: true,
            singleSelect: true,
            pagination: true,
            fit: true,
            url: '/sys/user/tree',
            queryParams: {
                _token: $('meta[name="csrf-token"]').attr('content'),
                curr_menu_id: $('meta[name="curr_menu_id"]').attr('content')
            },
            columns: [[
                {field: 'id', checkbox: true},
                {field: 'username', title: '用户名', width: 150, align: 'center'},
                {field: 'realname', title: '姓名', width: 100, align: 'center'},
                {
                    field: 'sex', title: '性别', width: 50, align: 'center', formatter: function (value) {
                    return value == 'M' ? '男' : '女';
                }
                },
                {field: 'phone', title: '手机号', width: 100, align: 'center'},
                {field: 'email', title: 'Email', width: 100, align: 'center'},
                {field: 'qq', title: 'QQ', width: 100, align: 'center'},
                {field: 'fax', title: '传真', width: 100, align: 'center'},
                {field: 'remark', title: '备注', width: 100, align: 'center'},
                {
                    field: 'is_active', title: '有效', width: 100, align: 'center', formatter: function (value) {
                    return value ===1 ? '生效' : '失效';
                }
                },
                {
                    field: 'is_admin', title: '管理员', width: 100, align: 'center', formatter: function (value) {
                    return value === 1 ? '是' : '否';
                }
                }
            ]],
            onLoadSuccess: function (data) {
                if (data === null || data.total === 0) {
                    var body = $(this).data().datagrid.dc.body2;
                    body.find('table tbody').append('<tr><td width="' + body.width() + '" style="height: 35px; text-align: center;"><h1>暂无数据</h1></td></tr>');
                }
            }
        });
    });
</script>